<@override name="content">
<div class="header">
  <h1 class="page-title">用户列表</h1>
</div>
<ul class="breadcrumb">
  <li>
    <a href="admin">首页</a>
    <span class="divider">/</span>
  </li>
  <li class="active">用户管理</li>
</ul>
<div class="container-fluid">
  <div class="row-fluid">
    <div class="well">
      <div id="container">
        <table id="user-list" class="table table-hover table-striped cf basetable dataTable" cellpadding="0"
               cellspacing="0" border="0" width="100%">
          <thead>
          <tr>
            <th width="5%">Id</th>
            <th width="10%">User</th>
            <th width="15%">Nick Name</th>
            <th width="10%">Real Name</th>
            <th width="10%">Email</th>
            <th width="10%">Phone</th>
            <th width="10%">QQ</th>
            <th width="5%">Solved</th>
            <th width="5%">Submit</th>
            <th width="10%">Register Time</th>
            <th width="10%">Action</th>
          </tr>
          </thead>
          <tbody>
          </tbody>
        </table>
      </div>
    </div>
  </div>
</div>
</@override>

<@override name="scripts">
<link href="assets/DataTables-1.9.4/media/css/dataTables.bootstrap.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="assets/DataTables-1.9.4/media/js/jquery.dataTables.js"></script>
<script type="text/javascript" src="assets/js/dataTables.bootstrap.js"></script>
<script type="text/javascript">
  var oTable = $('#user-list').jfinalDataTable({
    "sAjaxSource": "/api/admin/userList",
    "aoColumns": [
      {"mData": "uid"},
      {
        "mData": "name",
        "mRender": function (data, type, full) {
          return '<a href="user/profile/' + full.name + '" target="_blank">' + data + '</a>';
        }
      },
      {
        "mData": "nick",
        "mRender": function (data, type, full) {
          var nick = (data || '');
          var encodedStr = nick.replace(/[\u00A0-\u9999<>\&]/gim, function (i) {
            return '&#' + i.charCodeAt(0) + ';';
          });
          return '<a href="user/profile/' + full.name + '" target="_blank" title="' + encodedStr + '">' + nick + '</a>';
        }
      },
      {
        "mData": "realName",
        "mRender": function (data, type, full) {
          return (data || '');
        }
      },
      {
        "mData": "email",
        "mRender": function (data, type, full) {
          var email = (data || full.regEmail || '');
          if (email != '') {
            email = '<a href="mailto:' + email + '">' + email + '</a>';
          }
          return email;
        }
      },
      {
        "mData": "phone",
        "mRender": function (data, type, full) {
          return (data || '');
        }
      },
      {
        "mData": "qq",
        "mRender": function (data, type, full) {
          return (data || '');
        }
      },
      {
        "mData": "solved",
        "mRender": function (data, type, full) {
          return '<a href="status/?name=' + full.name + '&result=0" target="_blank">' + data + '</a>';
        }
      },
      {
        "mData": "submission",
        "mRender": function (data, type, full) {
          return '<a href="status/?name=' + full.name + '" target="_blank">' + data + '</a>';
        }
      },
      {
        "mData": "ctime",
        "mRender": function (data, type, full) {
          return parseTimestamp(data);
        }
      },
      {
        "mData": null,
        "bSortable": false,
        "mRender": function (data, type, full) {
          var action = '<button id="user-edit" uid="' + full.uid
                  + '" class="btn btn-success">Edit</button> '
                  + '<button id="user-toggle" uid="' + full.uid
                  + '" class="btn btn-warning">'
                  + (full.status ? 'Delete' : 'Resume')
                  + '</button> ';
          return action;
        }
      }
    ]
  });
</script>
</@override>
<@extends name="../_layout.html"></@extends>
